From 6b59b9f752226c53d265fe6609d7e88f01fb0ab9 Mon Sep 17 00:00:00 2001 From: Hollis Blanchard Date: Mon, 19 Feb 2007 16:49:12 +0900 Subject: [PATCH] GNTTAB: PowerPC patch for dynamic grant tables. Grant table expansion is disabled for now, since we currently make assumptions about grant table MFNs being contiguous. Signed-off-by: Isaku Yamahata Signed-off-by: Hollis Blanchard --- xen/arch/powerpc/mm.c | 16 ++++++++++++++-- xen/common/grant_table.c | 2 ++ xen/include/asm-powerpc/config.h | 9 +++++++++ xen/include/asm-powerpc/grant_table.h | 4 ++-- xen/include/xen/grant_table.h | 4 ++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/xen/arch/powerpc/mm.c b/xen/arch/powerpc/mm.c index 5f257dcc85..96fddd3d5c 100644 --- a/xen/arch/powerpc/mm.c +++ b/xen/arch/powerpc/mm.c @@ -416,7 +416,13 @@ ulong pfn2mfn(struct domain *d, ulong pfn, int *type) if (pfn & foreign_map_pfn) { t = PFN_TYPE_FOREIGN; mfn = foreign_to_mfn(d, pfn); - } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) { + } else if (pfn >= max_page && pfn < + (max_page + nr_grant_frames(d->grant_table))) { + /* XXX access d->grant_table->nr_grant_frames without lock. + * Currently on powerpc dynamic expanding grant table is + * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES + * so that this access is safe. + */ /* Its a grant table access */ t = PFN_TYPE_GNTTAB; mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page)); @@ -494,9 +500,15 @@ unsigned long mfn_to_gmfn(struct domain *d, unsigned long mfn) ulong gnttab_mfn; ulong rma_mfn; + /* XXX access d->grant_table->nr_grant_frames without lock. + * Currently on powerpc dynamic expanding grant table is + * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES + * so that this access is safe. + */ /* grant? */ gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0); - if (mfn >= gnttab_mfn && mfn < (gnttab_mfn + NR_GRANT_FRAMES)) + if (mfn >= gnttab_mfn && mfn < + (gnttab_mfn + nr_grant_frames(d->grant_table))) return max_page + (mfn - gnttab_mfn); /* IO? */ diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 642a3af4a9..1af842a528 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -35,8 +35,10 @@ #include #include +#ifndef max_nr_grant_frames unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES; integer_param("gnttab_max_nr_frames", max_nr_grant_frames); +#endif /* The maximum number of grant mappings is defined as a multiplier of the * maximum number of grant table entries. This defines the multiplier used. diff --git a/xen/include/asm-powerpc/config.h b/xen/include/asm-powerpc/config.h index 86366406f0..02702b1489 100644 --- a/xen/include/asm-powerpc/config.h +++ b/xen/include/asm-powerpc/config.h @@ -73,4 +73,13 @@ extern char __bss_start[]; #include +/* + * Disallow grant table growing tempralily because pfn2mfn() and + * mfn_to_gmfn() depends on the fact that grant table is machine-address + * contiguous. Grant table growing breaks the assumption. + */ +#ifndef max_nr_grant_frames +#define max_nr_grant_frames INITIAL_NR_GRANT_FRAMES +#endif + #endif diff --git a/xen/include/asm-powerpc/grant_table.h b/xen/include/asm-powerpc/grant_table.h index a50e51fca7..334a925cbb 100644 --- a/xen/include/asm-powerpc/grant_table.h +++ b/xen/include/asm-powerpc/grant_table.h @@ -41,11 +41,11 @@ int destroy_grant_host_mapping( #define gnttab_create_shared_page(d, t, i) \ do { \ share_xen_page_with_guest( \ - virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)), \ + virt_to_page((t)->shared[(i)]), \ (d), XENSHARE_writable); \ } while ( 0 ) -#define gnttab_shared_mfn(d, t, i) (((ulong)((t)->shared) >> PAGE_SHIFT) + (i)) +#define gnttab_shared_mfn(d, t, i) (virt_to_mfn((t)->shared[(i)])) #define gnttab_shared_gmfn(d, t, i) \ (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i))) diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h index 5ae9149bc1..0164668e2c 100644 --- a/xen/include/xen/grant_table.h +++ b/xen/include/xen/grant_table.h @@ -56,10 +56,14 @@ struct active_grant_entry { #define INITIAL_NR_GRANT_ENTRIES ((INITIAL_NR_GRANT_FRAMES << PAGE_SHIFT) / \ sizeof(grant_entry_t)) +#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */ /* Default maximum size of a grant table. [POLICY] */ #define DEFAULT_MAX_NR_GRANT_FRAMES 32 +#endif +#ifndef max_nr_grant_frames /* to allow arch to override */ /* The maximum size of a grant table. */ extern unsigned int max_nr_grant_frames; +#endif /* * Tracks a mapping of another domain's grant reference. Each domain has a -- 2.30.2